__author__ = 'Paul'
from zope.interface import alsoProvides
from kss.core import kssaction
from plone.app.kss.plonekssview import PloneKSSView
from plone.app.layout.globals.interfaces import IViewView
from Acquisition import aq_inner
from Products.Five.browser import BrowserView


class ListMonthEvents(PloneKSSView):
    @kssaction
    def list_events(self, mes,agno):
        mes=int(mes)
        agno=int(agno)
        if mes-1==0:
            agno=agno-1
        else:
            mes=mes-1

        # Now send the command back that we should refresh this viewlet
        # Because the viewlet is registered for IViewView, we need to
        # mark the KSS view (self) with this first.
        alsoProvides(self, IViewView)
        ksscore = self.getCommandSet('core')
        zopecommands = self.getCommandSet('zope')
        #selector = ksscore.getHtmlIdSelector('portletItemDetails')
        selector = ksscore.getHtmlIdSelector('portletItemDetails')
        selector1 = ksscore.getHtmlIdSelector('prevMes')
        ksscore.replaceInnerHTML(selector,
            '<h1>Parameters: %s, %s</h1>' % (mes, agno))
        ksscore.replaceInnerHTML(selector1,
            '<a href="#" class="listMonthEvents \ kssattr-year-%s \ kssattr-month-%s" id="prevMes">%s</a>' %(agno,mes,mes))




    def ant_events(self,mes,agno):
        mes=int(mes)
        agno=int(agno)
        if mes-1==0:
            agno=agno-1
        else:
            mes=mes-1
        alsoProvides(self, IViewView)

        ksscore = self.getCommandSet('core')
        zopecommands = self.getCommandSet('zope')
        #selector = ksscore.getHtmlIdSelector('portletItemDetails')
        selector = ksscore.getHtmlIdSelector('portletItemDetails')

        ksscore.replaceInnerHTML(selector,'<h1>Parameters: %s, %s</h1>' %(agno,mes))
